package zcjq.d912;

import java.util.Arrays;
import java.util.Scanner;

/**
 * 猫
 */
public class P3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = Integer.parseInt(scanner.nextLine().trim());
        while (t-- > 0) {
            int n = Integer.parseInt(scanner.nextLine().trim());
            int[] nums = Arrays.stream(scanner.nextLine().trim().split("\\s+")).mapToInt(Integer::parseInt).toArray();
            int[] max = new int[]{0};
            bt(nums, 0, 0, 0, max);
            System.out.println(max[0]);
        }
    }

    private static void bt(int[] nums, int begin, int total, int count, int[] max) {
        if (begin == nums.length) {
            max[0] = Math.max(max[0], count);
        } else {
            int num = nums[begin];
            if (total + num >= 0) {
                bt(nums, begin + 1, total + num, count + 1, max);
            }
            bt(nums, begin + 1, total, count, max);
        }
    }


    private static void dp(int[] nums) {
        int len = nums.length;

    }


}
